package com.cqndt.disaster.device.common.config;

import java.io.IOException;
import java.lang.reflect.Type;
import org.springframework.http.HttpOutputMessage;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @Auther: huangdianyu
 * @Date: 2018/9/12
 * @Description: 返回参数加密converter
 **/
public class HttpMessageConverter extends MappingJackson2HttpMessageConverter {

    @Override
    protected void writeInternal(Object object,Type type,HttpOutputMessage outputMessage) 
    		throws IOException,HttpMessageNotWritableException {
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(object);
//        outputMessage.getBody().write(Base64Util.base64Encode(json).getBytes());
        outputMessage.getBody().write(json.getBytes());
    }
}